<template>
    <el-cascader
            v-model="val"
            :options="options"
            ref="cascader"
            v-bind="$attrs"
            :placeholder="placeholder"
            :props="props"
            @change="handleChange"
            :filterable="filterable"></el-cascader>
</template>

<script>
    export default {
        name: "EdCascader",
        props:{
            value:{
                type: [String,Number,Array],
                default:function () {
                    return [];
                }
            },
            filterable: {
                type: Boolean,
                default: false
            }
        },
        data(){
            return{
                options:this.$attrs.cascaderParams.options || [],
                val:"",
                placeholder: this.$attrs.cascaderParams.placeholder || "请选择",
                props: this.$attrs.cascaderParams.props || {label:'label',value:'value',children:"children",emitPath:false,checkStrictly: true},
            }
        },
        watch:{
            '$attrs.cascaderParams.options'(val){
                this.options = val
            },
            value(val){
                this.val =val
            }
        },
        methods:{
            handleChange(event){
                this.$emit('input',event);
                this.$emit('change-emit-label',this.$refs.cascader.getCheckedNodes()[0].label);
            }
        }
    }
</script>

<style scoped>

</style>